#include <iostream>
#include <time.h>

#include "NeuralNet.h"
#include "Utils.h"



void main(int argc, char *argv[])
{
	if( argc > 1)
		cout << "A guardar em: " << argv[1] << endl;

	srand(static_cast<unsigned>(__rdtsc()));

	// .04109
	CNeuralNet net(500, 28, 51, 0.1, 0.0, 0.01);

	CData data;
	data.LoadTrainData();
	double errMin= 100, errMax=0;
	double average = 0;
	for(int i = 0; i < 10; i++)
	{
		//cout << i+1 << '-' ;
		net.Reset();
		net.Train(&data);
		average += net.Error();

		if(net.Error() > errMax)
			errMax = net.Error();

		if(net.Error() < errMin)
		{ 
			errMin = net.Error();
			if( argc > 1)
				net.SaveNetworkToFile(string(argv[1]));
			else
				net.SaveNetworkToFile(string("weights.dat"));
		}
	}

	average /= 10;
	cout << "Min: " << errMin << endl;
	cout << "Max: " << errMax << endl;
	cout << "Average: " << average;
	getchar();

}